package com.lanren.androidanimations;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

public class EffectAdapter extends BaseAdapter {

    private Context mContext;
    private List<AnimaBean> list;

    public EffectAdapter(Context context, List<AnimaBean> list) {
        mContext = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @SuppressLint({"InflateParams", "ViewHolder"})
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        View view;
        ViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            view = LayoutInflater.from(mContext).inflate(R.layout.item, null, false);
            viewHolder.name = (TextView) view.findViewById(R.id.list_item_text);
            view.setTag(viewHolder);
        } else {
            view = convertView;
            viewHolder = (ViewHolder) view.getTag();
        }
        AnimaBean o = (AnimaBean) getItem(position);
        viewHolder.name.setText(o.getName());
        return view;
    }

    class ViewHolder {
        TextView name;
    }
}
